//
//  ConvenientlyTakeAPIRequest.m
//  ConvenientlyTake
//
//  Created by 张奇 on 2022/12/22.
//

#import "ConvenientlyTakeAPIRequest.h"
#define KPageSize 15

@implementation ConvenientlyTakeAPIRequest

/// 随手拍-分页查询事件列表
/// @param randomClapState 随手拍状态(1-待受理; 2-处置中；3-已办结; 4-不予受理)
/// @param success success
/// @param fail fail
+(NSURLSessionDataTask *)GETEventWithRandomClapState:(NSInteger)randomClapState
                                                page:(NSInteger)page
                                             success:(LZTResponseSuccess)success fail:(LZTResponseFailure)fail {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setValue:@(page) forKey:@"page"];
    [parameters setValue:@(KPageSize) forKey:@"pageSize"];
    if (randomClapState > 0) {
        [parameters setObject:@(randomClapState) forKey:@"randomClapState"];
    }
    
    return [self GETWithURLString:@"/api/m/event/findMyEventByPageForApp" parameters:parameters success:success failure:fail];
}

/// 获取所有事件类型
/// @param keyword 关键字
/// @param success success
/// @param fail fail
+(NSURLSessionDataTask *)GETEventTypeWithKeyword:(NSString *)keyword
                                         success:(LZTResponseSuccess)success fail:(LZTResponseFailure)fail {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setValue:R(keyword) forKey:@"keyword"];
    
    return [self GETWithURLString:@"api/public/event-type/findAll" parameters:parameters success:success failure:fail];
}

/// 实地调查组新增
/// @param problemDescription 问题描述
/// @param promoterPhone 联系方式
/// @param province 省
/// @param city 市
/// @param county 县/区
/// @param address 详细地址
/// @param longitude 经度
/// @param latitude 纬度
/// @param eventType 事件类型
/// @param imagesList 照片 "fileType":文件类型(1-图片；2-视频)  fileName:文件名  文件路径:文件路径
/// @param videoList 视频 "fileType":文件类型(1-图片；2-视频)  fileName:文件名  文件路径:文件路径
/// @param success success
/// @param fail fail
+(NSURLSessionDataTask *)POSTConvenientTakeAddWithProblemDescription:(NSString *)problemDescription
                                                       promoterPhone:(NSString *)promoterPhone
                                                            province:(NSString *)province
                                                                city:(NSString *)city
                                                              county:(NSString *)county
                                                             address:(NSString *)address
                                                           longitude:(NSString *)longitude
                                                            latitude:(NSString *)latitude
                                                           eventType:(NSString *)eventType
                                                          imagesList:(NSArray *)imagesList
                                                           videoList:(NSArray *)videoList
                                                             success:(LZTResponseSuccess)success fail:(LZTResponseFailure)fail {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    
    [parameters setObject:R(problemDescription) forKey:@"problemDescription"];
    [parameters setObject:R(promoterPhone) forKey:@"promoterPhone"];
    [parameters setObject:R(province) forKey:@"province"];
    [parameters setObject:R(city) forKey:@"city"];
    [parameters setObject:R(county) forKey:@"county"];
    [parameters setObject:R(address) forKey:@"address"];
    [parameters setObject:R(longitude) forKey:@"longitude"];
    [parameters setObject:R(latitude) forKey:@"latitude"];
    [parameters setObject:R(eventType) forKey:@"eventType"];
    [parameters setObject:imagesList forKey:@"imagesList"];
    [parameters setObject:videoList forKey:@"videoList"];
    
    return [self POSTWithURLString:@"/api/public/event/add" parameters:parameters success:success failure:fail];
}

/// 随手拍-事件详情
/// @param eventId id
/// @param success success
/// @param fail fail
+(NSURLSessionDataTask *)GETEventDetailWithEventId:(NSString *)eventId
                                         success:(LZTResponseSuccess)success fail:(LZTResponseFailure)fail {
    NSString *url = [NSString stringWithFormat:@"api/m/event/getAppEventDetails/%@", eventId];
    
    return [self GETWithURLString:url parameters:nil success:success failure:fail];
}

@end
